import Vue from 'vue'
import Router from 'vue-router'
import store from '../store/index.js';
Vue.use(Router)

const login = r => require.ensure([], () => r(require('@/views/login')), 'login');
const manage = r => require.ensure([], () => r(require('@/views/home/manage')), 'manage');
const isadmin = r => require.ensure([], () => r(require('@/views/home/isadmin')), 'isadmin');




const routes = [{
		path: '/',
		component: login

	},
	{
		path: '/isadmin',
		component: isadmin,
	},
	{
		path: '/manage',
		component: manage,
		name: '',
		meta: {
			requiresAdmin: true
		}
	}
]

const router = new Router({
	routes
});

// router.beforeEach((to, from, next) => {
// 	if (to.matched.some(record => record.meta.requiresAdmin)) {
// 		const istoken = store.state.token;
// 		// const istoken =
// 		// 	'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiLlkJXkvJrlvZUiLCJtY19qd3RfIjoibWNfand0XyIsImV4cCI6MTY5MjQ0MTg5MiwidXNlcklkIjo0OTIsImlhdCI6MTY5MjM1NTQ5MiwianRpIjoiY2Q1OTk3M2ItMWZkNi00NDBhLWE2YmMtOGZhODhkZWMyNTQ3In0.IwHdpz-7-kqO0gkXpxhBKeybzDJy2-Yc_-agIE3Q0fI'
// 		console.log(istoken)
// 		if (istoken) {
// 			next();
// 		} else {
// 			next('/');
// 		}
// 	} else {
// 		next();
// 	}
// });

export default router;